# 导包
import time
from selenium import webdriver
from selenium.webdriver.common.by import By


class Testcase:
    # 打开浏览器
    def __init__(self):
        self.driver = webdriver.Chrome()

    def get(self):
        # 输入网址
        self.driver.get('https://zhipin.com')
        # 获取输入框
        query = self.driver.find_element(By.NAME, 'query')
        # 输入内容
        query.send_keys('软件测试')
        # 获取搜索按钮
        search = self.driver.find_element(By.CLASS_NAME, 'btn-search')
        # 单击搜索按钮
        search.click()

    def print_title(self):
        # 打印网页标题
        time.sleep(3)
        print(self.driver.title)

    def quit(self):
        # 关闭浏览器
        time.sleep(3)
        self.driver.quit()

    def window_max(self):
        time.sleep(2)
        # 设置窗口大小
        self.driver.set_window_size(400, 800)
        time.sleep(2)
        # 窗口最大化
        self.driver.maximize_window()
        time.sleep(2)
        # 窗口最小化
        self.driver.minimize_window()

    def refresh(self):
        time.sleep(2)
        # 刷新
        self.driver.refresh()

    def forward_back(self):
        time.sleep(2)
        # 后退
        self.driver.back()
        time.sleep(2)
        # 前进
        self.driver.forward()

    def close(self):
        # 关闭标签
        self.driver.close()


if __name__ == '__main__':
    case = Testcase()
    case.get()
    # case.print_title()
    # case.forward_back()
    # case.refresh()
    case.close()
    case.quit()

